﻿#include "mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
{
    resize(QSize(1920,1080));
    init_ctrl();
    load_style();
    init_data();
}

MainWindow::~MainWindow()
{

}

void MainWindow::init_ctrl()
{
    btn_ui_switch_ctrl_ = new QPushButton("switch ctrl ui",this);
    btn_ui_prechn_ = new QPushButton("pre chn ui",this);
    vbox_ui_model_ = new QVBoxLayout;
    vbox_ui_model_->addWidget(btn_ui_switch_ctrl_);
    vbox_ui_model_->addWidget(btn_ui_prechn_);

    ptr_ui_chn_switch_ = new WindowBasicChnSwitch(this);
}

void MainWindow::load_style()
{

}

void MainWindow::init_data()
{
    e_module_ = UI_MODEL_UNKONW;
    ptr_ui_chn_switch_->hide();
    switch_ui(UI_MODEL_SWITCH_CTRL);
}

void MainWindow::switch_ui(UI_MODEL_TYPE model)
{
    if(model == e_module_) return;

    if(model == UI_MODEL_SWITCH_CTRL) {
        ptr_ui_chn_switch_->show();
    }
    e_module_ = model;
}

void MainWindow::resizeEvent(QResizeEvent *event)
{
    int w = event->size().width();
    int h = event->size().height();

    vbox_ui_model_->setGeometry(QRect(10, 100, 200, 100));
    ptr_ui_chn_switch_->setGeometry(300, 100, 800, 260);
    event->accept();
}
